<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="/WebFinalProject/css/FinalProjectCSS.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Manage Question Pool</title>
<script type="text/javascript" src="validationWithJs.js"></script>
<script type="text/javascript" src="table.js"></script>
<script type="text/javascript">
	function manage(task, id) {
		document.forms[0].task.value = task;
		document.forms[0].id.value = id;
		document.forms[0].submit();
	}
	
	function flyToPage(task) {
		document.forms[0].task.value = task;
		document.forms[0].submit();
	}
	
	function setFilePath() {
		var str = document.forms[0].elements['filePath'].value;
		var res = str.substr(str.lastIndexOf("\\") + 1);

		document.forms[0].elements['qModel.fileName'].value = res;
		alert(res);
	}
	
	function checkOut(task) {
		document.forms[0].task.value = task;
		path=document.forms[0].elements['qModel.fileName'].value;
 		if(checkFile(path)){
			document.forms[0].submit();
 		}else{
 			alert("Please select file to upload!");
 		}
	}
</script>
</head>

<%
	if(session.getAttribute("result") != null)
	{
		String message = session.getAttribute("result").toString();
		%>
			<script type="text/javascript">
				window.alert('<%=message%>');
			</script>
		<%
		session.removeAttribute("result");
	}
%> 

<body onkeydown="javascript:disableF5(event, '');">
	<center>
		<table width="100%" class="bodyTable boxShadow">

			<!-- Header -->
			<tr>
				<td colspan="2"><%@include file="/include/Header.jsp"%></td>
			</tr>

			<!-- Content -->
			<tr>
				<td rowspan="2" width="200px" class="navigationBox"><%@include file="/include/Navigation.jsp"%></td>
				<td align="left" class="headerBox blueBackground">Setting > Manage Question Pool</td>
			</tr>
			<tr>
				<td align="center" class="contentStyle formListStyle"><br> <html:form action="/Question" method="post" enctype="multipart/form-data">
					<html:hidden property="task" />
					<html:hidden property="id" />
					<html:hidden property="qModel.fileName" />
					<%-- 					<html:hidden property="idUpdate"/> --%>
						<table width="95%" class="boxShadow">
							<tr class="headerBox greyBackground">
								<td class="formListStyle leftAlign"> 
									Import Excel :
									<html:file property="filePath" onchange="javascript:setFilePath();" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									Exam For : 
									<html:select property="qModel.examFor" name="questionForm">
										<html:option value="Candidate">Candidate</html:option>
										<html:option value="Trainee">Trainee</html:option>
									</html:select>
									<html:select property="qModel.active" name="questionForm">
										<html:option value="1">Active</html:option>
										<html:option value="0">Inactive</html:option>
									</html:select>
								</td>
								<td colspan="1" class="formListStyle rightAlign">
									<table title="check out excel" class="buttonStyle" style="cursor: pointer;" onclick="javascript:checkOut('Excel');">
										<tr>
											<td style="vertical-align: middle;"><img src="images/checkButton.png"/></td>
											<td style="vertical-align: middle;"><b>&nbsp;Check Out&nbsp;</b></td>
										</tr>
									</table>
<!-- 									<input type="button" value="CEK SOAL" class="buttonStyle" onclick="javascript:flyToPage('Excel');"> -->
								</td>
							</tr>
						</table>
						
						<br/>
						<table width="95%" align="center" border="0" class="boxShadow  example table-autosort table-autofilter  table-autopage:10 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount" id="t1">
							<thead>
								<tr class="headerBox formHeaderBackground">
									<th colspan="4" align="center" class="formListStyle table-sortable:default">Question</th>
<!-- 									<th align="center" class="table-sortable:default" width="400px">Options</th> -->
<!-- 									<th align="center" class="table-sortable:default">Answer</th> -->
									<th align="center" class="formListStyle filterable table-sortable:default">Exam For</th>
									<th align="center" class="formListStyle filterable table-sortable:default">Class</th>
									<th align="center" class="formListStyle filterable table-sortable:default">Active</th>
									<!-- <th></th>
									<th align="center" class="formListStyle table-filterable table-sortable:default">Exam For</th>
									<th align="center" class="formListStyle table-filterable table-sortable:default">Class</th> -->
									<th></th>
								</tr>
								<tr>
									<th colspan="4" height="5px"></th>
									<th class="formListStyle table-filterable"></th>
									<th class="formListStyle table-filterable"></th>
									<th class="formListStyle table-filterable"></th>
									<th></th>
								</tr> 
							</thead>
							<tbody>
								<logic:notEmpty name="questionForm" property="listQuestion">
									<logic:iterate id="listData" name="questionForm" property="listQuestion">
										<tr class="formListBackground">
											<td colspan="4" class="formListStyle leftAlign topValign" style="line-height: 20px;" width="60%">
												<bean:write name="listData" property="question" filter="none"></bean:write>
											</td>
<!-- 											<td align="center" class="formListStyle"> -->
<%-- 												<bean:write name="listData" property="optionOfAnswer" filter="none"></bean:write> --%>
<!-- 											</td> -->
<!-- 											<td align="center" class="formListStyle"> -->
<%-- 												<bean:write name="listData" property="answer"></bean:write> --%>
<!-- 											</td> -->
											<td align="center" class="formListStyle topValign" width="100px">
												<bean:write name="listData" property="examFor"></bean:write>
											</td>
											<td align="center" class="formListStyle topValign" width="125px">
												<bean:write name="listData" property="className"></bean:write>
											</td>
											<td align="center" class="formListStyle topValign" width="100px">
												<bean:write name="listData" property="active"></bean:write>
											</td>
											<td align="center" class="formListStyle topValign">
												<img src="images/editButton.png" title="edit" style="cursor: pointer;" onclick="javascript:manage('update','<bean:write name="listData" property="questionPoolId"/>');"/>
<%-- 												<img src="images/deleteButton.png" title="delete" style="cursor: pointer;" onclick="javascript:manage('delete','<bean:write name="listData" property="questionPoolId"/>');"/> --%>
<%-- 												<input type="button" class="buttonStyle" value="Update" onclick="javascript:manage('edit','<bean:write name="listData" property="questionPoolId"/>');"> --%>
<%-- 												<input type="button" class="buttonStyle" value="Delete" onclick="javascript:manage('delete','<bean:write name="listData" property="questionPoolId"/>');"> --%>
											</td>
										</tr>
									</logic:iterate>
								</logic:notEmpty>
								<logic:empty name="questionForm" property="listQuestion">
									<tr class="formListBackground">
										<td align="center" colspan="8" class="formListStyle">Data is not found</td>
									</tr>
								</logic:empty>
							</tbody>
							
							<tfoot>
								<tr class="headerBox formHeaderBackground">
									<td width="80px" class="table-page:previous formListStyle" style="cursor:pointer;">&lt;&lt; Previous</td>
									<td colspan="6" style="text-align:center; vertical-align: middle;">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td>
									<td width="65px" align="right" class="table-page:next formListStyle" style="cursor:pointer;">Next &gt;&gt;</td>
								</tr>
								<tr>
									<td colspan="8" id="insertButton" title="add new" align="center" class="greyBackground">						
										<div class="insertButtonGridStyle" onclick="javascript:flyToPage('addQuestion');">
											<table>
												<tr>
													<td class="formListStyle"><img src="images/addButton.png"></td>
													<td class="formListStyle"><b>Add New Question</b></td>
												</tr>
											</table>
										</div>									
									</td>
<!-- 									<td colspan="7" align="center" style="vertical-align: middle; padding: 5px 7px;"> -->
<!-- 										<input type="button" value="Insert" class="buttonStyle" onclick="javascript:flyToEdit()" /> -->
<!-- 									</td> -->
								</tr>								
<!-- 								<tr> -->
<!-- 									<td class="table-page:previous" style="cursor: pointer; padding: 5px 7px;">&lt; &lt; Previous</td> -->
<!-- 									<td colspan="4" style="text-align: center; vertical-align: middle;">Page<span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td> -->
<!-- 									<td class="table-page:next" style="cursor: pointer; vertical-align: middle; padding: 5px 7px;">Next &gt; &gt;</td> -->
<!-- 								</tr> -->
								<tr>
									<td colspan="8" align="center" class="headerBox formHeaderBackground"><span id="t1filtercount"></span>&nbsp;of <span id="t1allcount"></span>&nbsp;rows match filter(s)</td>
								</tr>
							</tfoot>
						</table>
					
					</html:form><br>
				<br></td>
			</tr>

			<!-- Footer -->
			<tr>
				<td align="center" colspan="2" class="headerBox blueBackground">&copy; OME. 2014. All Rights Reserved.</td>
			</tr>
		</table>
	</center>
</body>
</html>